﻿package mortal.game.view.shop
{
    import Message.Game.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class BuyBackCellRenderer extends GCellRenderer
    {
        private var _buyBackIem:BaseItem;
        private var _sBuyBackItem:SBuyBackItem;

        public function BuyBackCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._buyBackIem = UICompomentPool.getUICompoment(BaseItem);
            this._buyBackIem.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            this._buyBackIem.isDragAble = false;
            this._buyBackIem.isDropAble = false;
            this._buyBackIem.isShowLock = true;
            this._buyBackIem.x = 5;
            this._buyBackIem.y = 5;
            this.addChild(this._buyBackIem);
            this._buyBackIem.configEventListener(MouseEvent.CLICK, this.buyBack);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._buyBackIem.dispose(param1);
            this._buyBackIem = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            if (param1.data == null)
            {
                this._sBuyBackItem = null;
                this._buyBackIem.itemData = null;
                return;
            }
            this._sBuyBackItem = param1.data as SBuyBackItem;
            var _loc_2:* = new SPlayerItem();
            _loc_2.uid = this._sBuyBackItem.uid;
            _loc_2.itemCode = this._sBuyBackItem.itemCode;
            _loc_2.itemAmount = this._sBuyBackItem.amount;
            _loc_2.jsStr = this._sBuyBackItem.jsStr;
            _loc_2.createDt = this._sBuyBackItem.createTime;
            var _loc_3:* = new ItemData(_loc_2);
            this._buyBackIem.itemData = _loc_3;
            return;
        }// end function

        private function buyBack(event:MouseEvent) : void
        {
            if (this._sBuyBackItem != null)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ShopBuyBack, this._sBuyBackItem.uid));
            }
            return;
        }// end function

    }
}
